﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebsiteDemo.Admin
{
    public partial class ThemUser : System.Web.UI.Page
    {        
        DataBaseDataContext db = new DataBaseDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                User us = new User();
                us.FullName = this.txtfullname.Text;
                us.UserName = this.txtusername.Text;
                us.Email = this.txtemail.Text;
                us.Password = this.txtpassword.Text;
                us.Status = Convert.ToBoolean(DropDownListStatus.SelectedValue);
                us.Description = this.txtdescription.Text;
                us.DateCreate = DateTime.ParseExact(this.txtdatecreate.Text,"dd/MM/yyyy",null);
                us.DateUpdate = DateTime.ParseExact(this.txtdateupdate.Text, "dd/MM/yyyy", null);
                us.DateLogin = DateTime.ParseExact(this.txtdatelogin.Text, "dd/MM/yyyy", null); 
                us.Address = this.txtaddress.Text;
                us.Country = this.txtcountry.Text;
                us.Phone = this.txtphone.Text;
                db.Users.InsertOnSubmit(us);
                db.SubmitChanges();
                Response.Redirect("TrangChu1.aspx");

            }
            catch {
                this.LabelMessage.Text = "Thêm User thất bại";
            }
        }
    }
}